package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysBidroom;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysBidder;
import com.ruoyi.system.service.ISysBidderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投标人管理Controller
 * 
 * @author ruoyi
 * @date 2024-08-01
 */
@RestController
@RequestMapping("/system/bidder")
public class SysBidderController extends BaseController
{
    @Autowired
    private ISysBidderService sysBidderService;

    /**
     * 查询投标人管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBidder sysBidder)
    {
        startPage();
        List<SysBidder> list = sysBidderService.selectSysBidderList(sysBidder);
        return getDataTable(list);
    }

    /**
     * 查询标室管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:lists')")
    @GetMapping("/lists")
    public AjaxResult lists(SysBidder SysBidder)
    {
        List<SysBidder> list = sysBidderService.selectSysBidderList(SysBidder);
        return success(list);
    }

    /**
     * 导出投标人管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:export')")
    @Log(title = "投标人管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBidder sysBidder)
    {
        List<SysBidder> list = sysBidderService.selectSysBidderList(sysBidder);
        ExcelUtil<SysBidder> util = new ExcelUtil<SysBidder>(SysBidder.class);
        util.exportExcel(response, list, "投标人管理数据");
    }

    /**
     * 获取投标人管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(sysBidderService.selectSysBidderById(id));
    }

    /**
     * 新增投标人管理
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:add')")
    @Log(title = "投标人管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBidder sysBidder)
    {
        return toAjax(sysBidderService.insertSysBidder(sysBidder));
    }

    /**
     * 修改投标人管理
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:edit')")
    @Log(title = "投标人管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBidder sysBidder)
    {
        return toAjax(sysBidderService.updateSysBidder(sysBidder));
    }

    /**
     * 删除投标人管理
     */
    @PreAuthorize("@ss.hasPermi('system:bidder:remove')")
    @Log(title = "投标人管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysBidderService.deleteSysBidderByIds(ids));
    }
}
